package com.lcy.testjta.controller;

import com.github.pagehelper.PageInfo;
import com.lcy.testjta.domain.car.User;
import com.lcy.testjta.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author player six
 * @email jslcylcy@163.com
 * @create 2018-03-29 10:50
 **/
@RestController
@RequestMapping("")
public class TestController {

    @Autowired
    private UserService userService;

    @GetMapping("/test")
    public String test() {
        return "test";
    }

    @PostMapping("")
    public String addUser() {
        User user = new User();
        user.setName("acasd");
        userService.insert(user);
        return "success";
    }

    @GetMapping("/list-page")
    public PageInfo<User> addUser(int page, int rows) {
        return userService.listByPage(page, rows);
    }
}
